import 'package:animal/constant/font.dart';
import 'package:animal/item/order_goods_item.dart';
import 'package:animal/ui/goods/Controller/confirm_order_controller.dart';
import 'package:animal/utils/screen_util.dart';
import 'package:animal/widgets/appbar_widget.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getwidget/getwidget.dart';

///商城——确认订单页面
class ConfirmOrderPage extends StatelessWidget {
  ConfirmOrderPage({Key? key}) : super(key: key);
  late ConfirmOrderController controller;

  @override
  Widget build(BuildContext context) {
    controller = Get.put(ConfirmOrderController());
    return Scaffold(
        appBar: AppBarWidget.defaultAppBar(
            title: Text("确认订单", style: KFontConstant.myTextStyle(size: 20, color: Colors.black, bold: true)), backgroundColor: Colors.white),
        body: Stack(
          alignment: Alignment.bottomCenter,
          children: [
            ListView.builder(
                padding: EdgeInsets.only(left: ScreenUtil().L(5), right: ScreenUtil().L(5), top: ScreenUtil().L(10), bottom: ScreenUtil().L(60)),
                itemCount: 3,
                shrinkWrap: true,
                itemBuilder: (context, index) {
                  return contentWidget();
                }),
            Container(
                margin: EdgeInsets.symmetric(horizontal: ScreenUtil().L(30),vertical: ScreenUtil().L(15)),
                child: GFButton(
                  onPressed: () {},
                  size: ScreenUtil().L(40),
                  child: Text(
                    "确认支付 ¥ 350",
                    style: KFontConstant.myTextStyle(size: 18, color: Colors.white),
                  ),
                  fullWidthButton: true,
                ))
          ],
        ));
  }

  contentWidget() {
    return Container(
      margin: EdgeInsets.symmetric(vertical: ScreenUtil().L(7.5)),
      decoration: BoxDecoration(color: Colors.white, border: Border.all(width: ScreenUtil().L(0.5)), borderRadius: BorderRadius.circular(ScreenUtil().L(10))),
      child: Column(
        children: [
          Container(
            decoration: BoxDecoration(border: Border(bottom: BorderSide(width: ScreenUtil().L(0.5), color: Colors.black))),
            child: Row(
              children: [
                Expanded(
                  child: Row(
                    children: [
                      Text("小渔具旗舰店", style: KFontConstant.myTextStyle(size: 14, bold: true)),
                      const Icon(Icons.chevron_right),
                    ],
                  ),
                ),
                GFIconButton(icon: const Icon(Icons.message), onPressed: () {}, type: GFButtonType.transparent)
              ],
            ),
          ),
          ListView.builder(
              itemCount: 2,
              shrinkWrap: true,
              physics: const NeverScrollableScrollPhysics(),
              padding: EdgeInsets.symmetric(horizontal: ScreenUtil().L(15)),
              itemBuilder: (context, index) {
                return OrderShopItem(controller: controller.controller);
              }),
          Divider(
            height: ScreenUtil().L(1),
            color: Colors.black26,
          ),
          Container(
            padding: EdgeInsets.symmetric(vertical: ScreenUtil().L(15)),
            margin: EdgeInsets.symmetric(horizontal: ScreenUtil().L(30)),
            decoration: BoxDecoration(
              border: Border(bottom: BorderSide(width: ScreenUtil().L(1), color: Colors.black26)),
            ),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  "配送方式",
                  style: KFontConstant.myTextStyle(size: 17),
                ),
                Text(
                  "自提",
                  style: KFontConstant.myTextStyle(size: 15),
                ),
              ],
            ),
          ),
          Container(
            padding: EdgeInsets.symmetric(vertical: ScreenUtil().L(15), horizontal: ScreenUtil().L(30)),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  "支付总额",
                  style: KFontConstant.myTextStyle(size: 17),
                ),
                Text(
                  "¥ 350",
                  style: KFontConstant.myTextStyle(size: 15, color: Colors.red),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}
